package com.gitee.wsl.mathematics.matrix.mat

import com.gitee.wsl.io.dataproxy.DataProxy
import com.gitee.wsl.io.dataproxy.asProxy
import com.gitee.wsl.mathematics.matrix.MatInitializer

open class FunMatrix(
    rowCount: Int,
    colCount: Int,
    valueFun:MatInitializer<Double>,
    proxy: DataProxy<Double> = FunDataProxy(rowCount * colCount,colCount,valueFun).asProxy()
): AbstractMatrix<FunMatrix>(rowCount, colCount, proxy) {

   override val self get() = this

}

class FunDataProxy(override val size: Int,
                   val colCount: Int,
                   val valueFun:MatInitializer<Double> ):DataProxy<Double>{

    override fun get(index: Int): Double{
        val row = index/colCount
        val col = index%colCount
        return valueFun(row,col)
    }

    override fun fill(value: Double, fromIndex: Int, toIndex: Int) {}

    override fun values(): List<Double> = (0..size).map { get(it) }

    override fun set(index: Int, value: Double) {}
}